<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//订单成功控制器
class successfulController extends Controller{
	private $model;
	public function __init(){
		//订单表
	    $this->model = new \Common\Model\indent;
	}
	//默认
	public function index(){
		//接收订单id
		$inid = Q("get.id",0,'intval');
		View::with('inid',$inid);
		//购物车页面判断用户有没有登录
		if(!isset($_SESSION['uid']) || !isset($_SESSION['username'])){
			View::error('请先登录！',U('Login/login'));
		}
		$username = $_SESSION['username'];
		View::with('username',$username);
		//订单表关联用户地址表,找到该用户收货地址
		$data = $this->model->join('user_address','uaid','=','in_address')->where("inid={$inid}")->find();
		View::with('data',$data);
	
		//载入模板
		View::make();
	}
	
	//支付成功
	public function paySuccess(){
		//接收订单id
		$inid = Q("get.inid",0,'intval'); 
		//支付,状态改为1
		if(IS_POST){
			$this->model->where("inid={$inid}")->save(array('in_status'=>1));
		}
		//用户名
		$username = $_SESSION['username'];
		View::with('username',$username);
		//载入模板
	    View::make();
	}
}